package acwing._2LanQiao._3Math_DP;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._3Math_DP
 * @File : Q0895.java
 * @Author : WangRuoyu
 * @Date : 2023/3/15 8:57
 */

public class Q0895 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] words = line.split(" ");

        int n = Integer.parseInt(words[0]);

        int[] d = new int[n + 1];
        int[] f = new int[n + 1];

        line = br.readLine();
        words = line.split(" ");
        int res = 0;
        for (int i = 1; i <= n; ++i) {
            d[i] = Integer.parseInt(words[i - 1]);
            for (int j = 1; j < i; ++j) {
                if (d[i] > d[j]) {
                    f[i] = Math.max(f[i], f[j]);
                }
            }
            f[i] += 1;
            res = Math.max(res, f[i]);
        }

        System.out.println(res);
    }
}

//7
//3 1 2 1 8 5 6